<%--
  Created by IntelliJ IDEA.
  User: 86186
  Date: 2025/6/25
  Time: 14:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>用户添加</title>
</head>
    <style type="text/css">
        body {
            margin: 10px 10px 0 10px;
        }

        a{
            text-decoration:none;
            color: blue;

        }

        a:visited{
            color: blue;
        }

        a:hover{

            color: red;
        }

        #head{
            margin-bottom: 30px;
        }

        #content div{
            line-height: 30px;
            margin:10px;

        }

        .container{
            display:flex;
            justify-content: center;

        }

        .left{
            width:160px;
            text-align: right;
        }

        .right{
            width: 400px;
            box-sizing: border-box;
            padding-left: 10px;
        }

        .right input[type=text]{
            border-radius: 5px;
            outline: none;
            height: 30px;
            border: 1px solid black;
            width: 300px;
        }

        .right input,select:focus{
            box-shadow: 0 0 3px #9FB8F7;
        }

        select{
            height: 30px;
            width: 300px;
        }

        .btnDiv{
            box-sizing: border-box;
            padding: 10px 0;
            text-align: center;
        }

        .btnDiv input{
            height: 30px;
            border: 1px solid black;
            width: 80px;
        }
    </style>

    <script type="application/javascript">
        function saveUser() {
            let flag = true;
            if(document.getElementById("workCode").value===""){
                flag= false;
            }
            if(document.getElementById("username").value===""){
                flag= false;
            }
            if(document.getElementById("password").value===""){
                flag= false;
            }

            if(flag){
                document.getElementById("addForm").submit();
            }else{
                alert("请填写完整的表单信息！！！");
            }

        }

        function cancel() {
            location.href = "./user_list.action";
        }
    </script>
<body>
    <div id="head">
        <a href="./user_list.action">返回列表</a>
    </div>
    <div id="content">
        <div id="errDiv" style="color: red; height: 30px;">
            ${requestScope.message}
        </div>
        <form id="addForm"  method="post" action="./user_insert.action">
            <input type="hidden" id="id" name="id" value="${requestScope.user.id}">
            <div class="container">
                <div class="left">
                    员工工号:
                </div>
                <div class="right">
                    <input type="text" id="workCode" name="workCode" value="${requestScope.user.workCode}">
                </div>
            </div>
            <div class="container">
                <div class="left">
                    员工姓名:
                </div>
                <div class="right">
                    <input type="text" id="username" name="username" value="${requestScope.user.username}">
                </div>
            </div>
            <div class="container">
                <div class="left">
                    账号密码:
                </div>
                <div class="right">
                    <input type="text" id="password" name="password" value="${requestScope.user.password}">
                </div>
            </div>
            <div class="container">
                <div class="left">
                    选择部门:
                </div>
                <div class="right">
                    <select name="department" id="department">
                        <option value="">请选择</option>
                        <c:forEach var="entry" items="${applicationScope.departMap}">
                            <c:if test="${entry.key==requestScope.user.department}">
                            <option value="${entry.key}" selected>${entry.value}</option>
                            </c:if>
                            <c:if test="${entry.key!=requestScope.user.department}">
                                <option value="${entry.key}">${entry.value}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="container">
                <div class="left">
                    选择岗位:
                </div>
                <div class="right">
                    <select name="post" id="post">
                        <option value="">请选择</option>
                        <c:forEach var="entry" items="${applicationScope.jobMap}" >
                            <c:choose >
                                <c:when test="${entry.key==requestScope.user.post}">
                                    <option value="${entry.key}" selected>${entry.value}</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="${entry.key}">${entry.value}</option>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="container">
                <div class="left">
                    选择性别:
                </div>
                <div class="right">
                    <input style="width: 15px;height: 15px;" type="radio" value="男" name="gender" checked>男
                    <input style="width: 15px;height: 15px;" type="radio" value="女" name="gender">女
                </div>
            </div>
            <div class="container">
                <div class="left">
                    联系电话:
                </div>
                <div class="right">
                    <input type="text" id="telephone" name="telephone" value="${requestScope.user.telephone}">
                </div>
            </div>
            <div class="container">
                <div class="left">
                    出生日期:
                </div>
                <div class="right">
                    <input type="date" id="birthDate" name="birthDate" value="${requestScope.user.birthDate}">
                </div>
            </div>
            <div class="container">
                <div class="left">
                    邮箱:
                </div>
                <div class="right">
                    <input type="text" id="email" name="email" value="${requestScope.user.email}">
                </div>
            </div>
            <div class="btnDiv">
                <input type="button" value="保存" onclick="saveUser()" style="background-color:cornflowerblue;">
                <input type="button" value="返回" onclick="cancel()">
            </div>
        </form>


    </div>


</body>
</html>
